<!--<script>-->
<!--export default {-->
<!--  name: 'Home'-->
<!--}-->
<!--</script>-->

<!--<template>-->
<!-- <div>-->
<!--&lt;!&ndash;  <h1>欢迎来到航空管理页面</h1>&ndash;&gt;-->
<!--&lt;!&ndash;  <router-view></router-view>&ndash;&gt;-->
<!-- </div> -->
<!--</template>-->

<!--<style scoped>-->
<!--.read-the-docs {-->
<!--  color: #888;-->
<!--}-->
<!--</style>-->

<template>
  <el-container style="min-height: 100vh">
    <el-aside width="sideWidth+'px'" style="background-color: rgb(255,255,255)"> <!--width="sideWidth+'px'"导航栏动态宽度-->
      <el-menu :default-openeds="['1', '3']" style="min-height: 100%; overflow-x: hidden"
               background-color="rgb(48,65,86)"
               text-color="#fff"
               active-text-color="#ffd04b"
               :collapse-transition="false"
               :collapse="isCollapse"
      > <!--active-text-color="#ffd04b"点击导航栏文字时候高亮黄色。  :collapse-transition="false"关闭动画（为了收缩导航栏做铺垫）
        :collapse="isCollapse"控制展开折叠
        -->
        <div style="height: 60px; line-height: 60px; text-align: center">
          <img src="../assets/logo.png" alt="" style="width: 30px;position: relative; top: 10px;margin-right: 10px">
          <b style="color: white" v-show="logoTextShow">后台管理系统</b>
        </div>
        <el-submenu index="1">
          <template slot="title">
            <i class="el-icon-message"></i>
            <span slot="title">导航一</span>
          </template>
          <el-menu-item-group>
            <template slot="title">分组一</template>
            <el-menu-item index="1-1">选项1</el-menu-item>
            <el-menu-item index="1-2">选项2</el-menu-item>
          </el-menu-item-group>
          <el-menu-item-group title="分组2">
            <el-menu-item index="1-3">选项3</el-menu-item>
          </el-menu-item-group>
          <el-submenu index="1-4">
            <template slot="title">选项4</template>
            <el-menu-item index="1-4-1">选项4-1</el-menu-item>
          </el-submenu>
        </el-submenu>
        <el-submenu index="2">
          <template slot="title"><i class="el-icon-menu"></i>
            <span slot="title">导航二</span>
          </template>
          <el-menu-item-group>
            <template slot="title">分组一</template>
            <el-menu-item index="2-1">选项1</el-menu-item>
            <el-menu-item index="2-2">选项2</el-menu-item>
          </el-menu-item-group>
          <el-menu-item-group title="分组2">
            <el-menu-item index="2-3">选项3</el-menu-item>
          </el-menu-item-group>
          <el-submenu index="2-4">
            <template slot="title">选项4</template>
            <el-menu-item index="2-4-1">选项4-1</el-menu-item>
          </el-submenu>
        </el-submenu>
        <el-submenu index="3">
          <template slot="title"><i class="el-icon-setting"></i>
            <span slot="title">导航三</span>
          </template>
          <el-menu-item-group>
            <template slot="title">分组一</template>
            <el-menu-item index="3-1">选项1</el-menu-item>
            <el-menu-item index="3-2">选项2</el-menu-item>
          </el-menu-item-group>
          <el-menu-item-group title="分组2">
            <el-menu-item index="3-3">选项3</el-menu-item>
          </el-menu-item-group>
          <el-submenu index="3-4">
            <template slot="title">选项4</template>
            <el-menu-item index="3-4-1">选项4-1</el-menu-item>
          </el-submenu>
        </el-submenu>
      </el-menu>
    </el-aside>

    <el-container>
      <el-header style="font-size: 12px;border-bottom: 1px solid #ccc; line-height: 60px;display:flex">
        <div style="flex: 1; font-size: 25px">
          <!-- 👆收缩栏图标-->
          <span :class="collapseBtnClass" style="cursor: pointer" @click="collapse"></span>
        </div>
        <el-dropdown style="width: 100px;cursor:pointer">
          <span>王小虎</span><i class="el-icon-arrow-down" style="margin-left: 5px"></i>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item>个人信息</el-dropdown-item>
            <el-dropdown-item>退出</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>

      </el-header>
      <el-main>
        <!--下面这个div盒子是搜索框和搜索按钮 -->
        <div style="margin: 10px 0">
          <el-input style="width: 200px" placeholder="请输入名称" suffix-icon="el-icon-search"></el-input>
          <el-button class="ml-5" type="primary">搜索</el-button>
        </div>
      </div>
      <!-- todo 内容组件 -->
<!--      <router-view/>-->
      <el-tabs v-if="$route.meta.isTab" v-model="mainTabsActiveName" :closable="true"
               @tab-click="selectedTabHandle" @tab-remove="removeTabHandle">

        <el-table :data="tableData" border stripe: header-cell-class-name="headerBg">
          <el-table-column prop="date" label="日期" width="140">
          </el-table-column>
          <el-table-column prop="name" label="姓名" width="120">
          </el-table-column>
          <el-table-column prop="address" label="地址">
          </el-table-column>
          <!-- 表格里面添加编辑和删除的按钮  -->
          <el-table-column label="操作">
            <template v-slot="scope">
              <el-button type="success">编辑 <i class="el-icon-edit"></i></el-button>
              <el-button type="danger">删除 <i class="el-icon-remove-outline"></i></el-button>
            </template>
          </el-table-column>

              <router-view v-if="item.name === mainTabsActiveName" />

            </el-card>
          </el-tab-pane>
        </el-scrollbar>
      </el-tabs>
      <div v-else>
        <el-scrollbar ref="scroll" :height="siteContentViewHeight+32+'px'" @scroll="scroll">
          <!-- 主入口标签页 e -->
          <el-card :style="'min-height:'+ siteContentViewHeight + 'px'">
            <router-view />
          </el-card>
        </el-scrollbar>
      </div>
    </div>
  </div>
</template>

<script>

export default {
  components: {

  },
  data: function() {
    return {
      isCollapse: false,
      mainTabs: [],
      mainTabsActiveName: '',
      menuActiveName: '',
      menus: []
    }
  },
  created() {
    let that = this;
    that.routeHandle(that.$route);
  },
  // 监听路由变化
  watch: {
    $route: {
      handler(to, from) {
        if (to.path != from.path) {
          // 处理路由
          this.routeHandle(to);
        }
      }
    }
  },
  methods: {
    resetDocumentClientHeight: function() {
      this.documentClientHeight = document.documentElement['clientHeight'];
      window.onresize = () => {
        this.documentClientHeight = document.documentElement['clientHeight'];
        this.loadSiteContentViewHeight();
      };
    },
    loadSiteContentViewHeight: function() {
      let height = this.documentClientHeight - 52; //减去导航栏高度50
      console.log(this.$route.meta.isTab)
      if (this.$route.meta.isTab) {
        height -= 70; //减去tab栏高度40,减去上下边距30
        /* this.siteContentViewHeight = {
          'min-height': height + 'px'
        }; */
        this.siteContentViewHeight = height;
      } else {
        height -= 30;
        //给内容区设置高度
        this.siteContentViewHeight = height;
      }

    },
    routeHandle: function(route) {
      //每次切换页面，重新计算页面高度和内容区高度
      this.resetDocumentClientHeight();
      this.loadSiteContentViewHeight();
      if (route.meta.isTab) {
        // tab选中, 不存在先添加
        var tab = this.mainTabs.filter(item => item.name === route.name)[0];
        if (!tab) {
          if (route.meta.isDynamic) {
            route = this.dynamicMenuRoutes.filter(item => item.name === route.name)[0];
            if (!route) {
              return console.error('未能找到可用标签页!');
            }
          }
          tab = {
            menuId: route.meta.menuId || route.name,
            name: route.name,
            title: route.meta.title,
            iframeUrl: route.meta.iframeUrl || '',
            params: route.params,
            query: route.query
          };
          this.mainTabs = this.mainTabs.concat(tab);
        }
        this.menuActiveName = tab.menuId + '';
        this.mainTabsActiveName = tab.name;
      }
    },
    selectedTabHandle: function(tab, e) {
      tab = this.mainTabs.filter(item => item.name === tab.paneName);
      if (tab.length >= 1) {
        this.$router.push({
          name: tab[0].name,
          query: tab[0].query,
          params: tab[0].params
        });
      }
    },
    removeTabHandle: function(tabName) {
      this.mainTabs = this.mainTabs.filter(item => item.name !== tabName);
      if (this.mainTabs.length >= 1) {
        // 当前选中tab被删除
        if (tabName === this.mainTabsActiveName) {
          var tab = this.mainTabs[this.mainTabs.length - 1];
          this.$router.push({
                name: tab.name,
                query: tab.query,
                params: tab.params
              },
              () => {
                this.mainTabsActiveName = this.$route.name;
              }
          );
        }
      } else {
        this.menuActiveName = '';
        this.$router.push({
          name: 'Home'
        });
      }
    },
    mounted: function() {
      let that = this;
      that.resetDocumentClientHeight();
      that.loadSiteContentViewHeight();
    }
  }
}
</script>

<style>
@import url('../assets/css/home.css');
</style>



<!--&lt;!&ndash;<script>&ndash;&gt;-->
<!--&lt;!&ndash;export default {&ndash;&gt;-->
<!--&lt;!&ndash;  name: 'Home'&ndash;&gt;-->
<!--&lt;!&ndash;}&ndash;&gt;-->
<!--&lt;!&ndash;</script>&ndash;&gt;-->

<!--&lt;!&ndash;<template>&ndash;&gt;-->
<!--&lt;!&ndash; <div>&ndash;&gt;-->
<!--&lt;!&ndash;&lt;!&ndash;  <h1>欢迎来到航空管理页面</h1>&ndash;&gt;&ndash;&gt;-->
<!--&lt;!&ndash;&lt;!&ndash;  <router-view></router-view>&ndash;&gt;&ndash;&gt;-->
<!--&lt;!&ndash; </div> &ndash;&gt;-->
<!--&lt;!&ndash;</template>&ndash;&gt;-->

<!--&lt;!&ndash;<style scoped>&ndash;&gt;-->
<!--&lt;!&ndash;.read-the-docs {&ndash;&gt;-->
<!--&lt;!&ndash;  color: #888;&ndash;&gt;-->
<!--&lt;!&ndash;}&ndash;&gt;-->
<!--&lt;!&ndash;</style>&ndash;&gt;-->

<!--<template>-->
<!--  <el-container style="min-height: 100vh">-->
<!--    <el-aside width="sideWidth+'px'" style="background-color: rgb(255,255,255)"> &lt;!&ndash;width="sideWidth+'px'"导航栏动态宽度&ndash;&gt;-->
<!--      <el-menu :default-openeds="['1', '3']" style="min-height: 100%; overflow-x: hidden"-->
<!--               background-color="rgb(48,65,86)"-->
<!--               text-color="#fff"-->
<!--               active-text-color="#ffd04b"-->
<!--               :collapse-transition="false"-->
<!--               :collapse="isCollapse"-->
<!--      > &lt;!&ndash;active-text-color="#ffd04b"点击导航栏文字时候高亮黄色。  :collapse-transition="false"关闭动画（为了收缩导航栏做铺垫）-->
<!--        :collapse="isCollapse"控制展开折叠-->
<!--        &ndash;&gt;-->
<!--        <div style="height: 60px; line-height: 60px; text-align: center">-->
<!--          <img src="../assets/logo.png" alt="" style="width: 30px;position: relative; top: 10px;margin-right: 5px">-->
<!--          <b style="color: white" v-show="logoTextShow">后台管理系统</b>-->
<!--        </div>-->
<!--        <el-submenu index="1">-->
<!--&lt;!&ndash;          <template slot="title">&ndash;&gt;-->
<!--&lt;!&ndash;            <i class="el-icon-message"></i>&ndash;&gt;-->
<!--&lt;!&ndash;            <span slot="title">导航一</span>&ndash;&gt;-->
<!--&lt;!&ndash;          </template>&ndash;&gt;-->
<!--          <el-icon><Menu /></el-icon>-->
<!--          <span>导航一</span>-->
<!--          <el-menu-item-group>-->
<!--            <template slot="title">分组一</template>-->
<!--            <el-menu-item index="1-1">选项1</el-menu-item>-->
<!--            <el-menu-item index="1-2">选项2</el-menu-item>-->
<!--          </el-menu-item-group>-->
<!--          <el-menu-item-group title="分组2">-->
<!--            <el-menu-item index="1-3">选项3</el-menu-item>-->
<!--          </el-menu-item-group>-->
<!--          <el-submenu index="1-4">-->
<!--            <template slot="title">选项4</template>-->
<!--            <el-menu-item index="1-4-1">选项4-1</el-menu-item>-->
<!--          </el-submenu>-->
<!--        </el-submenu>-->
<!--        <el-submenu index="2">-->
<!--          <template slot="title"><i class="el-icon-menu"></i>-->
<!--            <span slot="title">导航二</span>-->
<!--          </template>-->
<!--          <el-menu-item-group>-->
<!--            <template slot="title">分组一</template>-->
<!--            <el-menu-item index="2-1">选项1</el-menu-item>-->
<!--            <el-menu-item index="2-2">选项2</el-menu-item>-->
<!--          </el-menu-item-group>-->
<!--          <el-menu-item-group title="分组2">-->
<!--            <el-menu-item index="2-3">选项3</el-menu-item>-->
<!--          </el-menu-item-group>-->
<!--          <el-submenu index="2-4">-->
<!--            <template slot="title">选项4</template>-->
<!--            <el-menu-item index="2-4-1">选项4-1</el-menu-item>-->
<!--          </el-submenu>-->
<!--        </el-submenu>-->
<!--        <el-submenu index="3">-->
<!--          <template slot="title"><i class="el-icon-setting"></i>-->
<!--            <span slot="title">导航三</span>-->
<!--          </template>-->
<!--          <el-menu-item-group>-->
<!--            <template slot="title">分组一</template>-->
<!--            <el-menu-item index="3-1">选项1</el-menu-item>-->
<!--            <el-menu-item index="3-2">选项2</el-menu-item>-->
<!--          </el-menu-item-group>-->
<!--          <el-menu-item-group title="分组2">-->
<!--            <el-menu-item index="3-3">选项3</el-menu-item>-->
<!--          </el-menu-item-group>-->
<!--          <el-submenu index="3-4">-->
<!--            <template slot="title">选项4</template>-->
<!--            <el-menu-item index="3-4-1">选项4-1</el-menu-item>-->
<!--          </el-submenu>-->
<!--        </el-submenu>-->
<!--      </el-menu>-->
<!--    </el-aside>-->

<!--    <el-container>-->
<!--      <el-header style="font-size: 12px;border-bottom: 1px solid #ccc; line-height: 60px;display:flex">-->
<!--        <div style="flex: 1; font-size: 25px; width: 100vw" id="fold">-->
<!--          &lt;!&ndash; 👆收缩栏图标&ndash;&gt;-->
<!--&lt;!&ndash;          <span :class="collapseBtnClass" style="cursor: pointer" @click="collapse"></span>&ndash;&gt;-->
<!--          <div style="flex: 1; font-size: 25px; width: 100vw" id="fold">-->
<!--            <el-icon v-if="!isCollapse"><Fold style="cursor: pointer" @click="collapse"/></el-icon>-->
<!--            <el-icon v-else><Expand style="cursor: pointer" @click="expand"/></el-icon>-->
<!--          </div>-->
<!--        </div>-->
<!--        <el-dropdown style="width: 100px;cursor:pointer">-->
<!--          <span>王小虎</span><i class="el-icon-arrow-down" style="margin-left: 5px"></i>-->
<!--          <el-dropdown-menu slot="dropdown">-->
<!--            <el-dropdown-item>个人信息</el-dropdown-item>-->
<!--            <el-dropdown-item>退出</el-dropdown-item>-->
<!--          </el-dropdown-menu>-->
<!--        </el-dropdown>-->

<!--      </el-header>-->
<!--      <el-main>-->
<!--        &lt;!&ndash;下面这个div盒子是搜索框和搜索按钮 &ndash;&gt;-->
<!--        <div style="margin: 10px 0">-->
<!--          <el-input style="width: 200px" placeholder="请输入名称" suffix-icon="el-icon-search"></el-input>-->
<!--          <el-button class="ml-5" type="primary">搜索</el-button>-->
<!--        </div>-->

<!--        &lt;!&ndash;  下面这个div盒子是新增、批量删除、导入导出按钮的  &ndash;&gt;-->
<!--        <div style="margin: 10px 0">-->
<!--          <el-button type="primary">新增<i class="el-icon-circle-plus-outline"></i></el-button>-->
<!--          <el-button type="danger">批量删除<i class="el-icon-remove-outline"></i></el-button>-->
<!--          <el-button type="danger">导入<i class="el-icon-bottom"></i></el-button>-->
<!--          <el-button type="danger">导出<i class="el-icon-top"></i></el-button>-->
<!--        </div>-->

<!--        <el-table :data="tableData" border stripe: header-cell-class-name="headerBg">-->
<!--          <el-table-column prop="date" label="日期" width="140">-->
<!--          </el-table-column>-->
<!--          <el-table-column prop="name" label="姓名" width="120">-->
<!--          </el-table-column>-->
<!--          <el-table-column prop="address" label="地址">-->
<!--          </el-table-column>-->
<!--          &lt;!&ndash; 表格里面添加编辑和删除的按钮  &ndash;&gt;-->
<!--          <el-table-column label="操作">-->
<!--            <template v-slot="scope">-->
<!--              <el-button type="success">编辑 <i class="el-icon-edit"></i></el-button>-->
<!--              <el-button type="danger">删除 <i class="el-icon-remove-outline"></i></el-button>-->
<!--            </template>-->
<!--          </el-table-column>-->


<!--        </el-table>-->
<!--        &lt;!&ndash;下边这个div盒子是添加进来可以分页的代码 &ndash;&gt;-->
<!--        <div style="padding: 10px 0">-->
<!--          <el-pagination-->

<!--              :page-sizes="[5, 10, 15, 20]"-->
<!--              :page-size="10"-->
<!--              layout="total, sizes, prev, pager, next, jumper"-->
<!--              :total="400">-->
<!--          </el-pagination>-->
<!--        </div>-->
<!--      </el-main>-->
<!--    </el-container>-->
<!--  </el-container>-->
<!--</template>-->

<!--<script>-->
<!--// @ is an alias to /src-->
<!--// import HelloWorld from '@/components/HelloWorld.vue'-->

<!--export default {-->
<!--  name: 'home',-->
<!--  data() {-->
<!--    const item = {-->
<!--      date: '2016-05-02',-->
<!--      name: '王小虎',-->
<!--      address: '上海市普陀区金沙江路 1518 弄'-->
<!--    };-->
<!--    return {-->
<!--      tableData: Array(20).fill(item),-->
<!--      // collapseBtnClass:'fold',-->
<!--      isCollapse:false,-->
<!--      sideWidth:200, //动态收缩导航栏初始值200-->
<!--      logoTextShow:true,-->
<!--      headerBg:'headerBg'-->
<!--    }-->
<!--  },-->
<!--  methods:{-->
<!--    collapse(){ //点击收缩按钮触发-->
<!--      this.isCollapse = !this.isCollapse-->
<!--      if (this.isCollapse){ //收缩-->
<!--        this.sideWidth = 64-->
<!--        this.logoTextShow=false-->
<!--      }-->
<!--    },-->
<!--    expand() {-->
<!--      this.isCollapse = !this.isCollapse-->
<!--      if(!this.isCollapse){-->
<!--        this.sideWidth = 200-->
<!--        this.logoTextShow=true-->
<!--      }-->
<!--    }-->
<!--  }-->
<!--}-->
<!--</script>-->

<!--&lt;!&ndash;顶部的横栏颜色定义&ndash;&gt;-->
<!--<style>-->

<!--.headerBg{-->
<!--  background: #ccc !important;-->
<!--}-->

<!--</style>-->
